﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NngLevelEditor.Manager;
using Microsoft.Xna.Framework;
using System.ComponentModel;
using NngLevelEditor.Utility;

namespace NngLevelEditor.Entities
{
    public class TwoPointEntity : SpriteEntity
    {
        protected Sprite _sprite2;
        protected Vector2 _position2;

        [DescriptionAttribute("The second position of the object.")]
        public Vector2 Position2
        {
            get { return _position2; }
            set
            {
                _position2 = value;
                _sprite2.Position = value;
            }
        }

        public TwoPointEntity()
        {
            //LoadContent();
        }

        public TwoPointEntity(string[] info)
        {
            LoadContent();

            Position = new Microsoft.Xna.Framework.Vector2(float.Parse(info[1]), float.Parse(info[2]));
            _type = int.Parse(info[3]);
            Position2 = new Vector2(float.Parse(info[4]), float.Parse(info[5]));
        }

        public override void LoadContent()
        {
            _path = "entities/necklace/";
            _type = 1;

            _position2 = new Vector2();
            _sprite2 = GraphicsManager.AddSprite(_path + "end");
            _sprite2.Position = Position2;
            _sprite2.Visible = false;

            base.LoadContent();
        }

        public override string GetFileString()
        {
            string fileString = "o " + _position.X + " " + _position.Y + " "
                              + _type + " " + Position2.X + " " + Position2.Y;
            return fileString + base.GetFileString();
        }

        public override void Select()
        {
            base.Select();
            _sprite2.Visible = true;
        }

        public override void Deselect()
        {
            base.Deselect();
            _sprite2.Visible = false;
        }
    }
}
